package org.ricks.tcp.rmi;


import org.ricks.tcp.rmi.handler.RMINotifyLoginParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.ServerSocket;
import java.net.Socket;
import java.rmi.AlreadyBoundException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.RMISocketFactory;

/**
 * Class Name: RMIServer.java<br>
 * Description: <br>
 * <p>
 * DateTime: 2022-12-29 21:12:12<br>
 * @author zhangzhongxing<br>
 * <br>
 */
public class RMIServer {
	
	private static Logger LOGGER = LoggerFactory.getLogger(RMIServer.class);
	
	private final static RMIServer INSTANCE = new RMIServer();
	
	public static RMIServer getInstance() {
		return INSTANCE;
	}
	
	////临时版本(保证内网有两个服务器可以切换)
	public void RMIRegistryTest() {

		try {
			LocateRegistry.createRegistry(8889);
			IRMINotifyLogin rnotifylogin = new RMINotifyLoginParams();
			Naming.bind("rmi://localhost:8889/RNotifyLogin",rnotifylogin);
		} catch (MalformedURLException | AlreadyBoundException| RemoteException e) {
			LOGGER.error("", e);
		}
	}

	
}
